//
//  LikeGongLvCollectionViewCell.m
//  礼物说
//
//  Created by dllo on 16/5/4.
//  Copyright © 2016年 sunzhichao. All rights reserved.
//

#import "LikeGongLvCollectionViewCell.h"

@interface LikeGongLvCollectionViewCell ()

@property (nonatomic, retain) BaseImageView *imgView;
@property (nonatomic, retain) BaseLabel * nameLabel;
@property (nonatomic, retain) BaseLabel * hotLabel;
@property (nonatomic, retain) BaseImageView *gongLvimgView;

@end

@implementation LikeGongLvCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self createCell];
    }
    return self;
}
- (void)dealloc{
    
    [_lable release];
    [_gongLvimgView release];
    [_imgView release];
    [_hotLabel release];
    [_nameLabel release];
    [_model release];
    [super dealloc];
}
- (void)setModel:(gongLv *)model{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    
    [_imgView sd_setImageWithURL:[NSURL URLWithString:_model.picture] placeholderImage:PLACEHOLDER_IMAGE];
    self.nameLabel.text = _model.name;
    _nameLabel.numberOfLines = 3;
    self.hotLabel.text = _model.like;
    
}

- (void)createCell{

    self.imgView = [[BaseImageView alloc] init];
    [self.contentView addSubview:_imgView];
    [_imgView release];
 
    self.nameLabel = [[BaseLabel alloc] init];
    [self.contentView addSubview:_nameLabel];
    [_nameLabel release];
    _nameLabel.textColor = [UIColor whiteColor];
    
    self.hotLabel = [[BaseLabel alloc] init];
    [self.contentView addSubview:_hotLabel];
    [_hotLabel release];
    _hotLabel.textColor = [UIColor redColor];
    
    self.lable = [[BaseLabel alloc] init];
    [self.contentView addSubview:_lable];
    [_lable release];
    
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes{
    
    [super layoutSubviews];
    
    _imgView.frame = CGRectMake(0, kWIDTHS(10), kWIDTHS(375) - kWIDTHS(20), kHEIGHTCELL - kWIDTHS(20));
    _imgView.layer.cornerRadius = 10;
    _imgView.layer.masksToBounds = YES;
    
    _nameLabel.frame = CGRectMake(kWIDTHS(100), kHEIGHTCELL - kWIDTHS(80), kWIDTHS(170), kHEIGHTS(60));

    _hotLabel.frame = CGRectMake(kWIDTHCELL - kWIDTHS(80), kWIDTHS(20), kWIDTHS(60), kWIDTHS(40));
    
    _lable.frame = CGRectMake(kWIDTHCELL - kWIDTHS(40), kHEIGHTS(10), kWIDTHS(50), kHEIGHTS(30));
    _lable.font = [UIFont boldSystemFontOfSize:17];
    _lable.text = @"删除";
    _lable.hidden = YES;
    
    
}


@end
